
#pragma once

#include "Button.h"
#include "../FileTools.h"
#include "Panel.h"

//#define TREE_VIEW_ITEM_INVALID_HANDLE	0

template < class T > class SuperTree;

//-------------------------------------------------------------------
//                          TreeView
//-------------------------------------------------------------------

class TreeView : public Panel
{
	public:

		// ___________________ Functions _______________________

		TreeView( Widget* pxParent );
		virtual ~TreeView();
	
		virtual void	Render( );
		virtual void	Update( );

		virtual void	SetDefaultBeginDragDropCallback	( const BeginDragDropCallback pfnBeginDragDrop );
		virtual void	SetDefaultDragOverCallback		( const DragOverCallback pfnDragOver );
		virtual void	SetDefaultEndDragDropCallback	( const EndDragDropCallback pfnEndDragDrop );

		virtual void	PopulateFromFileTree	( SuperTree< FFileInfo >* pxFileTree );
		//virtual u_int	AddTreeItem			( const char* szLabel, const u_int uParent = TREE_VIEW_ITEM_INVALID_HANDLE );

		virtual bool	CanHaveChildren			( ) { return false; }

		static void		BackButtonCallback		( void* pxInstance );
		void			_BackButtonCallback		( );

		virtual Widget* FindChildWidgetAt		( const u_int uX, const u_int uY );	// Override this because we have widgets inside us that aren't children

	private:

		// ___________________ Functions _______________________

		void UpdateCurrentRoot( const FHandle uNewRoot );

		void PopulateFromFileTreeInternal ( SuperTree< FFileInfo >* pxFileTree, const FHandle xRoot );

		// ___________________ Variables _______________________

		SuperTree<Button>*			m_pxTreeViewItems;
		FHandle						m_xCurrentRoot;

		Button*						m_pxBackButton;
		
		BeginDragDropCallback		m_pfnDefaultBeginDragFunc;
		DragOverCallback			m_pfnDefaultDragOverFunc;
		EndDragDropCallback			m_pfnDefaultEndDragFunc;
};

// eof
